package com.dingli.DAO;

import com.dingli.utils.DataSourceUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.math.BigInteger;
import java.sql.SQLException;

public class LineDAO {
    private QueryRunner runner = new QueryRunner(DataSourceUtil.getDataSource());

    public int addLine(String lineName,String passby, int siteNum){
        String sql = "insert into Line(lineName,passby,siteNum)values(?,?,?)";
        try {
            BigInteger res = runner.insert(sql,new ScalarHandler<BigInteger>(), lineName, passby, siteNum);
            return res.intValue();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
